import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location){
	return originalPush.call(this, location).catch(err => err)
}
import approvals from './moduls/approvals'
import departments from './moduls/departments'
import attendances from './moduls/attendances'
import employees from './moduls/employees'
import permissions from './moduls/permissions'
import salarys from './moduls/salarys'
import social_securitys from './moduls/social_securitys'
import settings from './moduls/settings'
import deposit from './moduls/deposit'
import information from './moduls/information'
import platform from './moduls/platform'
import register from './moduls/register'
import password from './moduls/password'
import puyeest from './moduls/puyeest'
import huedion from './moduls/huedion'
import evaluate from './moduls/evaluate'
// 动态网页，可以访问不同的网页
// 管理员路由
export const asyncRoutes = [
	     // 动态路由，不同用户可以访问不同的页面
    {			
	   path: "/home",
	   name: "home",
	   meta:{title:'首页',icon:"hognbao", isShow: true},
	   component: () => import('@/views/Home.vue'),
	   children: [
       approvals,
       attendances,
       departments,
       employees,
       permissions,
       salarys,
       settings,
       social_securitys,
	   deposit,
	   information,
	   platform,
	   register,
	   password,
	   puyeest,
	   huedion,
	   evaluate
	]}
]

// 组件路由
export const asyncRoutese = [

	{	
	
	path: "/home",
	name: "home",
	meta:{title:'首页',icon:"hognbao" ,isShow: true,},
	component: () => import('@/views/Home.vue'),
	children: [
		 // 组件查看详细
		 {
			path:'elessent',
			name:'elessent',
			meta:{
				showTabBar:true,
				title:'查看详细'
			},
			component: () => import('../views/Manageent/components/elessent.vue')
		},
		// 组件查看详细
		{
			path:'enter',
			name:'enter',
			meta:{
				showTabBar:true,
			title:'查看详细'
			},
			component: () => import('../views/Manageent/components/enter')
		},
		//组件作品审核
		{
			path:'check',
			name:'check',
			meta:{
				showTabBar:true,
				title:"审核信息"
			},
			component: () => import ('../views/production/components/check.vue')
		},
		// 组件富文本新增装修知识
		{
			path:'snippets',
			name:'snippets',
			meta:{
				showTabBar:true,
				title:'新增装修知识'
			},
			component: () => import ('../views/harticle/components/snippets.vue')
		},
		// 新增文章避坑
		{
			path:'addarticle',
			name:'addarticle',
			meta:{
			 showTabBar:true,
			 title:'新增文章避坑'
			},
			component: () => import ('../views/harticle/components/addarticle.vue')
		},
		// 新增经典案例
		{
			path:'addClassic',
			name:'addClassic',
			meta:{
			 showTabBar:true,
			 title:'新增经典案例'
			},
			component: () => import ('../views/harticle/components/addClassic.vue')
		},
		// 经典案例编辑
		{
			path:'addclass',
			name:'addclass',
			meta:{
			 showTabBar:true,
			 title:'编辑经典案例'
			},
			component: () => import ('../views/harticle/children/addclass.vue')
		},
		// 装修避坑编辑
		{
			path:'defract',
			name:'defract',
			meta:{
			 showTabBar:true,
			 title:'编辑装修避坑'
			},
			component: () => import ('../views/harticle/children/defract.vue')
		},
		// 装修知识编辑
		{
			path:'snipngd',
			name:'snipngd',
			meta:{
				showTabBar:true,
				title:'编辑装修知识'
			},
			component: () => import ('../views/harticle/children/snipngd.vue')
		},
		// 装修知识避坑查看详细
		{
		 path:'imagetext',
		 name:'imagetext',
		 meta:{
			showTabBar:true,
			title:'查看详情'
		 },
		 component: () => import ('../views/harticle/components/imagetext')
		},
		// 组件邀新提现查看详细
		{
			path:'message',
			name:'message',
			meta:{
				showTabBar:true,
				title:'提现信息'
			},
			component: () => import('@/views/money/components/message.vue')
		},
		// 组件新曾版本管理
		{
			path:'addindex',
			name:'addindex',
			meta:{
				showTabBar:true,
				title:'新增版本'
			},
			component: () => import('../views/versions/components/addindex')
		},
		// 邀新提现
		{
			 path:'withdraw',
			name:'withdraw',
			meta:{
				showTabBar:true,
				title:'邀新提现'
			},
			component: () => import('../views/money/components/withdraw')
		},
		// 订单详情
		 {
			path:'particulars',
			name:'particulars',
			meta:{
				keepAlive:true,
				showTabBar:true,
				title:'订单详情',
			},
			component: () => import('../views/Employees/components/particulars')
		 },
		//  商品编辑
		{
			path:'acctcpeol',
			name:'acctcpeol',
			meta:{
				showTabBar:true,
				title:'编辑商品',
			},
			component: () => import('../views/Dashboard/acctcpeol.vue')
		},
		//  定制服务查看详细
		{
			path:'customization',
			name:'customization',
			meta:{
				showTabBar:true,
				title:'服务详细'
			},
			component: () => import('../views/platform/components/customization.vue')
		},
		//  测试的玩意
		 {
			path:'index',
			name:'index',
			meta:{
				showTabBar:true,
				title:'打印表格'
			},
			component: () => import('../components/Hamburger/index')
		 },
	]
}

]
// 登录的路由
export const constantRoutes = [
	{
		path: "/",
		name:'商户',
		component: () => import('@/views/Loing.vue'),
	},
	{
		path: '/404',
		name:'404',
			meta:{
				showTabBar:true,
				title:'天地图'
			},
		component: () => import('@/views/404.vue'),
	  },

]
export const constant = [
	{
		path: "/cms",
		name:'管理员',
		component: () => import('@/views/lonindes.vue'),
	},

]
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: [...constantRoutes, ...asyncRoutes,...constant,...asyncRoutese],
//   routes: constantRoutes, constant
})
const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
